package com.hzncc.flowable_diboot.service.bpm;

import com.diboot.core.vo.Pagination;
import com.hzncc.flowable_diboot.vo.bpm.BpmProcessInstanceCreateReqVO;
import com.hzncc.flowable_diboot.vo.bpm.BpmProcessInstanceReqVO;
import com.hzncc.flowable_diboot.vo.bpm.BpmProcessInstanceRespVO;
import org.flowable.engine.delegate.event.FlowableCancelledEvent;
import org.flowable.engine.runtime.ProcessInstance;

import java.util.List;

/**
 * @Description :
 * @Date : 2024/6/20
 * @Author : ChenJin
 * @Version : v1.0.0
 **/
public interface BpmProcessInstanceService {

    /**
     * 获取流程实例列表信息
     * @param reqVO
     * @param pagination
     * @return
     */
    List<BpmProcessInstanceRespVO> getBpmProcessInstanceList(BpmProcessInstanceReqVO reqVO, Pagination pagination);

    /**
     * 获取流程实例
     * @param instanceId
     * @return
     */
    BpmProcessInstanceRespVO getBpmProcessInstance(String instanceId);

    /**
     * 创建流程示例
     * @param createReqVO
     * @return
     */
    String createProcessInstance(BpmProcessInstanceCreateReqVO createReqVO);

    /**
     * 审批不通过时,修改流程实例
     * @param id
     * @param reason
     */
    void updateProcessInstanceWhenReject(String id, String reason);

    /**
     * 更新 ProcessInstance 拓展记录为取消
     *
     * @param event 流程取消事件
     */
    void updateProcessInstanceWhenCancel(FlowableCancelledEvent event);

    /**
     * 更新 ProcessInstance 拓展记录为完成
     *
     * @param instance 流程任务
     */
    void updateProcessInstanceWhenApprove(ProcessInstance instance);

    /**
     * 根据ID获取流程实例
     * @param id
     * @return
     */
    ProcessInstance getProcessInstance(String id);

    /**
     * 取消流程实例
     * @param id
     */
    void cancelProcessInstance(String id,String cancelReason);

}
